<template>
  <button 
    class="editor-button" 
    :class="[`size-${props.size}`, { 'is-block': props.block }]"
    :style="buttonStyle"
  >
    <i v-if="props.icon" class="button-icon" :class="props.icon"></i>
    <span>{{ props.text }}</span>
  </button>
</template>

<script setup lang="ts">
import { defineProps, computed } from 'vue';

const props = defineProps({
  text: {
    type: String,
    default: '按钮'
  },
  type: {
    type: String,
    default: 'primary'
  },
  size: {
    type: String,
    default: 'medium'
  },
  backgroundColor: {
    type: String,
    default: '#8B4513'
  },
  color: {
    type: String,
    default: '#FFFFFF'
  },
  borderRadius: {
    type: Number,
    default: 4
  },
  icon: {
    type: String,
    default: ''
  },
  link: {
    type: String,
    default: ''
  },
  block: {
    type: Boolean,
    default: false
  }
});

const buttonStyle = computed(() => {
  return {
    backgroundColor: props.backgroundColor,
    color: props.color,
    borderRadius: `${props.borderRadius}px`,
  };
});

defineOptions({
  name: 'editor-button'
});
</script>

<style lang="scss" scoped>
.editor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  
  &:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  }
  
  &:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  .button-icon {
    margin-right: 6px;
  }
  
  &.size-small {
    height: 32px;
    font-size: 12px;
  }
  
  &.size-medium {
    height: 40px;
    font-size: 14px;
  }
  
  &.size-large {
    height: 48px;
    font-size: 16px;
  }
  
  &.is-block {
    display: flex;
    width: 100%;
  }
}
</style> 